<template>
	<view class="login">
		<u-overlay :show="passStatus" :mask-click-able="false" :opacity="0.2">
			<view class="warp" style="display: flex;justify-content: center;align-items: center;margin-top: 39vh;">
				<view style="width: 130px;height: 130px;background-color: #000;border-radius: 10px;display: flex;align-items: center;justify-content: center;opacity:0.7">
					<u-loading-icon mode="semicircle" size="60" color="#FFF" :vertical="true" text="正在登录" textColor="#FFF"></u-loading-icon>
				</view>
			</view>
		</u-overlay>
	</view>
</template>

<script>
	// import croods from '@/common/croods-1.3.3.js';
	// window.croods = croods;
	// window.hydra =  require('../../common/wst_hydra-1.0.0.js');
	// import { mapState } from 'vuex';
	// import { getToken2 } from '@/common/api.js';
	export default {
		// computed: {
		// 	...mapState(['loginStatus','appVersion','loginMsg','isLogin','wsToken','nextUpdateToken','loginUserIdentity']),
		// },
		// data() {
		// 	return {
		// 		passStatus:false
		// 	}
		// },
		// methods: {
		// 	/* 新 */
		// 	loginVersionTwo(){
		// 		let that = this
				
		// 		/* 测试环境1 */
		// 		// setTimeout(function() {
		// 		// 	that.$store.commit('changeWsToken', "6444736ee8b0475c824c3e7f5747a062")
		// 		// 	that.$store.commit('changeNextUpdateToken', Date.now()+1200000)
		// 		// 	that.$store.commit('changeLoginUserIdentity', true)	
		// 		// 	that.$store.commit('loginStatusChange', true)
		// 		// 	that.$store.commit('isLoginChange', true)
		// 		// 	uni.switchTab({
		// 		// 		url: '/pages/hmss/index',
		// 		// 	})
		// 		// }, 500)
				
		// 		/* 测试环境2 */
		// 		getToken2({wstoken:"b8450f32ac9f45a5be9778bbd117900f"}).then(resL => {
		// 			setTimeout(function() {
		// 				that.$store.commit('changeWsToken', "b8450f32ac9f45a5be9778bbd117900f")
		// 				that.$store.commit('changeNextUpdateToken', Date.now()+1200000)
		// 				that.$store.commit('changeLoginUserIdentity', true)	
		// 				that.$store.commit('loginStatusChange', true)
		// 				that.$store.commit('isLoginChange', true)
		// 				uni.switchTab({
		// 					url: '/pages/hmss/index',
		// 				})
		// 			}, 500)
		// 		})
				
				
				/* 正式环境 */
				window.croods.customPlugin({
					action: "UserPlugin.login", 
					params: {},
					success: function(res) {
            alert(JSON.stringify(res.token))
						that.passStatus = true
						getToken2({wstoken:res.token}).then(resL => {
							that.$store.commit('changeWsToken', res.token)
							that.$store.commit('changeNextUpdateToken', Date.now()+1200000)
							if(resL.status){
								that.$store.commit('loginStatusChange', true)
								that.$store.commit('isLoginChange', true)
								that.$store.commit('getLoginMsg', resL.code)
								that.$store.commit('changeLoginUserIdentity', true)
								setTimeout(function() {
									uni.switchTab({
										url: '/pages/hmss/index',
									})
								}, 500)
							}else{
								that.$store.commit('loginStatusChange', false)
								that.$store.commit('isLoginChange', true)
								that.$store.commit('getLoginMsg', resL.code)
								that.$store.commit('changeLoginUserIdentity', false)	
								setTimeout(function() {
									uni.switchTab({
										url: '/pages/me/index',
									})
								}, 500)
							}
						}).catch(fail => {
							that.$store.commit('loginStatusChange', false)
							that.$store.commit('isLoginChange', true)
							that.$store.commit('getLoginMsg', "")
							that.$store.commit('changeWsToken', "")
							that.$store.commit('changeNextUpdateToken', Date.now()+1200000)
							that.$store.commit('changeLoginUserIdentity', false)	
							setTimeout(function() {
								uni.switchTab({
									url: '/pages/me/index',
								})
							}, 500)
						})
					}
				})
        
        
        
		// 	}
			
		// },
		// onShow() {
		// 	if(this.appVersion == 'X2'){
		// 		this.loginVersionTwo()
		// 	}
		// },
	}
</script>

<style>

</style>